package com.example.myapplication.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.myapplication.R;
import com.example.myapplication.tools.BarTransparent;

public class LoginActivity extends AppCompatActivity {
    private EditText username;
    private EditText password;
    private TextView login;
    public static String cookie;
    //public static List<Artist> artistList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        BarTransparent.makeStatusBarTransparent(this);
        BarTransparent.setAndroidNativeLightStatusBar(this,true);
        setContentView(R.layout.activity_login);
        username = findViewById(R.id.username);
        password = findViewById(R.id.password);
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        //登录你的网易云账号密码
        username.setText("");
        password.setText("");
        login = findViewById(R.id.login);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(TextUtils.isEmpty(username.getText().toString())||TextUtils.isEmpty(password.getText().toString())){
                    Toast toast = Toast.makeText(getApplicationContext(), "用户名或者密码不能为空", Toast.LENGTH_SHORT);
                    toast.setGravity(Gravity.CENTER, 0, 0);
                    toast.show();
                }
                else{
                        Intent intent = new Intent();
                        Bundle bundle = new Bundle();
                        bundle.putString("username",username.getText().toString());
                        bundle.putString("password",password.getText().toString());
                        intent.putExtras(bundle);
                        intent.setClass(LoginActivity.this,LoadingActivity.class);//跳转到加载界面
                        startActivity(intent);
                        finish();
                }
            }
        });

    }

}